<?php


use Phinx\Seed\AbstractSeed;

class AdminMenuSeeder extends AbstractSeed
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * https://book.cakephp.org/phinx/0/en/seeding.html
     */
    public function run (): void {
        $data = '[{"id":1,"menu_name":"系统管理","menu_symbol":"SystemManagement","menu_icon":"lock","menu_type":1,"menu_affix":0,"menu_visible":1,"menu_cache":0,"api_name":"","api_path":"","api_method":"GET","list_order":0,"parent_id":0,"delete_time":null},{"id":2,"menu_name":"权限组管理","menu_symbol":"PermissionGroup","menu_icon":"","menu_type":1,"menu_affix":0,"menu_visible":1,"menu_cache":0,"api_name":"","api_path":"/admin/permission","api_method":"GET","list_order":0,"parent_id":1,"delete_time":null},{"id":3,"menu_name":"菜单管理","menu_symbol":"PermissionMenu","menu_icon":"","menu_type":1,"menu_affix":0,"menu_visible":1,"menu_cache":0,"api_name":"","api_path":"/admin/menu","api_method":"GET","list_order":0,"parent_id":1,"delete_time":null},{"id":4,"menu_name":"管理员管理","menu_symbol":"PermissionUser","menu_icon":"","menu_type":1,"menu_affix":0,"menu_visible":1,"menu_cache":0,"api_name":"","api_path":"/admin/user","api_method":"GET","list_order":0,"parent_id":1,"delete_time":null},{"id":5,"menu_name":"添加权限组","menu_symbol":"PermissionGroupCreate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/permission","api_method":"POST","list_order":0,"parent_id":2,"delete_time":null},{"id":6,"menu_name":"编辑权限组","menu_symbol":"PermissionGroupUpdate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/permission/{id}","api_method":"PUT","list_order":0,"parent_id":2,"delete_time":null},{"id":7,"menu_name":"删除权限组","menu_symbol":"PermissionGroupDelete","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/permission/{id}","api_method":"DELETE","list_order":0,"parent_id":2,"delete_time":null},{"id":8,"menu_name":"添加菜单","menu_symbol":"PermissionMenuCreate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/menu","api_method":"POST","list_order":0,"parent_id":3,"delete_time":null},{"id":9,"menu_name":"编辑菜单","menu_symbol":"PermissionMenuUpdate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/menu/{id}","api_method":"PUT","list_order":0,"parent_id":3,"delete_time":null},{"id":10,"menu_name":"删除菜单","menu_symbol":"PermissionMenuDelete","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/menu/{id}","api_method":"DELETE","list_order":0,"parent_id":3,"delete_time":null},{"id":11,"menu_name":"新增管理员","menu_symbol":"PermissionUserCreate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/user","api_method":"POST","list_order":0,"parent_id":4,"delete_time":null},{"id":12,"menu_name":"编辑管理员","menu_symbol":"PermissionUserUpdate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/user/{id}","api_method":"PUT","list_order":0,"parent_id":4,"delete_time":null},{"id":13,"menu_name":"删除管理员","menu_symbol":"PermissionUserDelete","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/user/{id}","api_method":"DELETE","list_order":0,"parent_id":4,"delete_time":null},{"id":17,"menu_name":"配置管理","menu_symbol":"SystemSettings","menu_icon":"","menu_type":1,"menu_affix":0,"menu_visible":1,"menu_cache":1,"api_name":"","api_path":"","api_method":"GET","list_order":0,"parent_id":1,"delete_time":null},{"id":18,"menu_name":"添加配置","menu_symbol":"SystemSettingsCreate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings","api_method":"POST","list_order":0,"parent_id":17,"delete_time":null},{"id":19,"menu_name":"编辑配置","menu_symbol":"SystemSettingsUpdate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/{id}","api_method":"PUT","list_order":0,"parent_id":17,"delete_time":null},{"id":20,"menu_name":"删除配置","menu_symbol":"SystemSettingsDelete","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/{id}","api_method":"DELETE","list_order":0,"parent_id":17,"delete_time":null},{"id":21,"menu_name":"添加配置项","menu_symbol":"SystemSettingItemCreate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/{id}/item","api_method":"POST","list_order":0,"parent_id":17,"delete_time":null},{"id":22,"menu_name":"编辑配置项","menu_symbol":"SystemSettingItemUpdate","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/{id}/item/{itemId}","api_method":"PUT","list_order":0,"parent_id":17,"delete_time":null},{"id":23,"menu_name":"删除配置项","menu_symbol":"SystemSettingItemDelete","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/{id}/item/{itemId}","api_method":"DELETE","list_order":0,"parent_id":17,"delete_time":null},{"id":24,"menu_name":"保存配置值","menu_symbol":"SystemSettingItemValueSave","menu_icon":"","menu_type":2,"menu_affix":0,"menu_visible":0,"menu_cache":0,"api_name":"","api_path":"/admin/settings/save","api_method":"POST","list_order":0,"parent_id":17,"delete_time":null}]';
        $data = json_decode($data, true);
        $now = date('Y-m-d H:i:s');
        $data = array_map(function ($item) use ($now) {
            $item['create_time'] = $now;
            $item['update_time'] = $now;
            return $item;
        }, $data);
        $table = $this->table('admin_menu');
        $table->truncate();
        $table->insert($data)->save();
    }
}
